package factory;

/**
 * 使用工厂创建对象-简单工厂
 *
 * @author ycc
 * @date 2024/4/1
 * 工厂设计模式是一种创建型设计模式，它提供了一种创建对象的接口，允许类将实例化延迟到子类进行，而不需要指定具体的类.
 */
public class Client {
    public static void main(String[] args) {
        AnimalFactory dogFactory = new DogFactory();
        Animal dog = dogFactory.createAnimal();
        dog.speak();

        AnimalFactory catFactory = new CatFactory();
        Animal cat = catFactory.createAnimal();
        cat.speak();

        AnimalFactory birdFactory = new BirdFactory();
        Animal bird = birdFactory.createAnimal();
        bird.speak();
    }
}
